home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Halma 1.1.source Folder / Halma ƒ / Shell ƒ / graphics.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-24  |  5.0 KB  |  123 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        graphics.h
  4.  
  5. Purpose:    This is the header file for graphics.c
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program in a file named "GNU General Public License".
  19. If not, write to the Free Software Foundation, 675 Mass Ave,
  20. Cambridge, MA 02139, USA.
  21.  
  22. \**********************************************************************/
  23.  
  24. #pragma once
  25.  
  26. #include "QDOffscreen.h"
  27.  
  28. typedef struct
  29. {
  30.     short                windowIndex;            /* index of window in program's window list */
  31.     short                windowWidth;            /* width of window content, in pixels */
  32.     short                windowHeight;            /* height of window content, in pixels */
  33.     short                windowType;                /* type of window (see IM Essentials, 4-80) */
  34.     short                windowDepth;            /* current pixel depth of window */
  35.     short                maxDepth;                /* maximum pixel depth of window */
  36.     Boolean                hasCloseBox;            /* window has a close box */
  37.     Boolean                offscreenNeedsUpdate;    /* TRUE if offscreen bitmap needs redrawing */
  38.     Boolean                isColor;                /* TRUE if color, FALSE if grayscale */
  39.     Point                initialTopLeft;            /* initial window bounds when opened */
  40.     Rect                windowBounds;            /* on screen rectangle of window content */
  41.     Str31                windowTitle;            /* pascal string, title of window */
  42. } WindowDataRec, *WindowDataPtr, **WindowDataHandle;
  43.  
  44. typedef short (*dispatchProcPtr)(WindowDataHandle theData, short theMessage, unsigned long misc);
  45.  
  46. typedef struct                                    /* exactly the same as WindowDataRec */
  47. {                                                /* + dispatchProc at end */
  48.     short                windowIndex;
  49.     short                windowWidth;
  50.     short                windowHeight;
  51.     short                windowType;
  52.     short                windowDepth;
  53.     short                maxDepth;
  54.     Boolean                hasCloseBox;
  55.     Boolean                offscreenNeedsUpdate;
  56.     Boolean                isColor;
  57.     Point                initialTopLeft;
  58.     Rect                windowBounds;
  59.     Str31                windowTitle;
  60.     dispatchProcPtr        dispatchProc;            /* called with message of windowish event */
  61. } ExtendedWindowDataRec, *ExtendedWindowDataPtr, **ExtendedWindowDataHandle;
  62.  
  63. enum                    /* messages passed to window's dispatch procedure */
  64. {
  65.     kNull=0,            /* on null event when window is active, frgrnd/bkgrnd */
  66.     kStartup,            /* on program startup */
  67.     kShutdown,            /* on program shutdown */
  68.     kInitialize,        /* just before window is created & shown */
  69.     kOpen,                /* just after window is created & shown */
  70.     kUpdate,            /* during window update -- draw contents to current grafport */
  71.     kClose,                /* just before window is closed -- this can cancel close */
  72.     kDispose,            /* just after window is closed/disposed */
  73.     kActivate,            /* on window activate event */
  74.     kDeactivate,        /* on window deactivate event */
  75.     kSuspend,            /* on program suspension (switched into background) */
  76.     kResume,            /* on program resuming (switching into foreground) */
  77.     kKeydown,            /* on keydown event when window is active & in foreground */
  78.     kMousedown,            /* on mousedown event in window content when active & in frgrnd */
  79.     kUndo,                /* specific to window */
  80.     kChangeDepth        /* offscreen bitmap just created or pixel depth changed */
  81. };
  82.  
  83. enum                    /* return codes from window dispatch procedure */
  84. {
  85.     kSuccess=0,            /* message handled, no further processing please */
  86.     kFailure,            /* message not handled, use default action if any */
  87.     kCancel                /* message refused, cancel action (only good with kClose) */
  88. };
  89.  
  90. /***************************************************************************************/
  91.  
  92. enum                    /* window indices in gTheWindow[] and gTheWindowData[] lists */
  93. {
  94.     kAbout=0,            /* about box */
  95.     kAboutMSG,            /* "About MSG" splash screen */
  96.     kHelp,                /* help window */
  97.     kBoardSize,            /* choose board size window */
  98.     kMainWindow            /* main graphics window */
  99. };
  100.  
  101. #define        NUM_WINDOWS                5        /* total number of windows (see above enum) */
  102.  
  103. extern    WindowPtr        gTheWindow[NUM_WINDOWS];
  104. extern    ExtendedWindowDataHandle
  105.                         gTheWindowData[NUM_WINDOWS];
  106.  
  107. Boolean InitTheGraphics(void);
  108. void ShutDownTheGraphics(void);
  109. void OpenTheWindow(short index);
  110. void GetMainScreenBounds(void);
  111. short GetWindowDepth(WindowDataHandle theData);
  112. short GetBiggestDeviceDepth(WindowDataHandle theData);
  113. Boolean WindowIsColor(WindowDataHandle theData);
  114. void UpdateTheWindow(ExtendedWindowDataHandle theData);
  115. Boolean CloseTheWindow(ExtendedWindowDataHandle theData);
  116. PicHandle DrawThePicture(PicHandle thePict, short whichPict, short x, short y);
  117. PicHandle ReleaseThePict(PicHandle thePict);
  118. Boolean SetPortToOffscreen(WindowDataHandle theData);
  119. void RestorePortToScreen(WindowDataHandle theData);
  120. GrafPtr GetOffscreenGrafPtr(WindowDataHandle theData);
  121. GrafPtr GetWindowGrafPtr(WindowDataHandle theData);
  122. void KillOffscreen(int index);
  123.